package com.yimi.yinhepda.utils;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.GridView;

/**
 * @author Administrator
 * @date 2018/1/8 0008
 */

public class CustomGridView extends GridView {

  public CustomGridView(Context context) {
    super(context);
  }

  public CustomGridView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public CustomGridView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  @TargetApi(Build.VERSION_CODES.LOLLIPOP) public CustomGridView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
  }

  @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    //  AT_MOST参数表示控件可以自由调整大小，最大不超过Integer.MAX_VALUE/4
    int height = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, View.MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, height);
  }
}
